<?php

namespace Application\Model;


use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class Contact implements InputFilterAwareInterface
{
	private $id;
	private $nom;
	public $prenom;
	//public $sexe;
	public $email;
	public $tel;
	public $addresse;
	public $message;
	 
	protected $inputFilter;

	public function exchangeArray($data)
	{
		$this->id        = (isset($data['id'])) ? $data['id'] : null;
		$this->nom      = (isset($data['nom'])) ? $data['nom'] : null;
		$this->prenom    = (isset($data['prenom'])) ? $data['prenom'] : null;
		//$this->sexe     = (isset($data['sexe'])) ? $data['sexe'] : null;
		$this->email     = (isset($data['email'])) ? $data['email'] : null;
		$this->tel     = (isset($data['tel'])) ? $data['tel'] : null;
		$this->addresse   = (isset($data['addresse'])) ? $data['addresse'] : null;
		$this->message = (isset($data['message'])) ? $data['message'] : null;
		
	}
	 
	public function getArrayCopy()
	{
		return get_object_vars($this);
	}
	 
	public function setInputFilter(InputFilterInterface $inputFilter)
	{
		throw new \Exception("Not used");
	}


	
	public function getInputFilter()
	{
		if (!$this->inputFilter) {
			
			
			$inputFilter = new InputFilter();
			$factory     = new InputFactory();

		/*	$inputFilter->add($factory->createInput(array(
					'name'     => 'id',
					'required' => true,
					'filters'  => array(
							array('name' => 'Int'),
					),
			)));*/

			$inputFilter->add($factory->createInput(array(
					'name'     => 'nom',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 2,
											'max'      => 20,
									),
							),
					),
			)));
			
			$inputFilter->add($factory->createInput(array(
					'name'     => 'prenom',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 2,
											'max'      => 25,
									),
							),
					),
			)));
			 
			/*$inputFilter->add($factory->createInput(array(
					'name'     => 'sexe',
					'validators' => array(
							array(
									'name'    => 'InArray',
									'options' => array(
											'haystack' => array(2,3),
											'messages' => array(
													'notInArray' => 'Please select your gender !'
											),
									),
							),
					),
			)));*/
			 
		/*	$inputFilter->add($factory->createInput(array(
					'name'     => 'hobby',
					'required' => true
			)));*/
			 
			 
			$inputFilter->add($factory->createInput(array(
					'name'     => 'email',
					'required' => true,
					'validators' => array(
							array(
									'name'    => 'EmailAddress'
							),
					),
			)));
			 
			$inputFilter->add($factory->createInput(array(
					'name'     => 'tel',
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 5,
											'max'      => 13,
									),
							),
					),
			)));
			 
			$inputFilter->add($factory->createInput(array(
					'name'     => 'addresse',
					'required' => true,
					'filters'  => array(
							array('name' => 'StripTags'),
							array('name' => 'StringTrim'),
					),
					'validators' => array(
							array(
									'name'    => 'StringLength',
									'options' => array(
											'encoding' => 'UTF-8',
											'min'      => 5,
											'max'      => 255,
									),
							),
					),
			)));
			 
		

			$this->inputFilter = $inputFilter;
		}

		return $this->inputFilter;
	}
}

?>